﻿/* Created by Ben Dummler, Subodh Shrestha
 * Contact: bdummler@gmail.com, forsubodh@gmail.com */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TravelExpertsManagementConsole
{
    public partial class Login : Form
    {
        public Login(frmContainer parent)
        {
            InitializeComponent();
            MdiParent = parent;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = tbUserName.Text;
            string password = tbPassword.Text;

            if (username == "" || password == "")
            {
                lblMessage.Text = "Invalid Login";
                return;
            }

            DataAccess<string> myDataAccess = new DataAccess<string>();
            int result = myDataAccess.checkLogin(username, password);
            if (result != -1)
            {
                frmContainer parent = (frmContainer)MdiParent;
                parent.accessLevel = result;
                parent.changeMenuItemState(true);
                parent.childHomePage = new Home(parent);
                parent.childHomePage.Show();
                this.Close();
            }
            else
            {
                lblMessage.Text = "Invalid Login";
            }
        }
    }
}
